Unify the two branches in the consistency proof check - #149
Merged
Conversation
Also replace prepending to the proof list with removing in the other branch. It makes it a little obvious how to implement this without making a copy of the proof. This should also hopefully make the relationship between inclusion and consistency proof evaluation clearer. While I'm here, use '1.' for the steps so we don't have to renumber it as it changes.
lukevalenta
approved these changes
Oct 6, 2025
lukevalenta
left a comment
Collaborator
There was a problem hiding this comment.
Nice refactor! Just a couple comments.
| 4. Right-shift `sn` once more. | ||
| 5. Compare `sn` to `0` and `r` to `root_hash`. If either is not equal, fail the proof verification. If all are equal, accept the proof. | ||
| 2. Otherwise, run the following: | ||
| 1. Set `fn` to `start`, `sn` to `end - 1`, and `tn` to `n - 1`. |
Collaborator
There was a problem hiding this comment.
As I'm re-implementing this logic, I found a panic in the original version of my code when n = 0 due to an underflow. The fact that [start, end) is a subtree of the tree of size n implies that 0 <= start < end <= n so it must be the case that end > 0 and n > 0, but maybe we should add an explicit note about that?
Collaborator
Author
There was a problem hiding this comment.
Hmm... how about we just make the function check the preconditions? It's fallible anyway, and makes it consistent with the inclusion proof version. Arguably it's redundant with the "type signature" but people will be sloppy.
lukevalenta
added a commit
to cloudflare/azul
that referenced
this pull request
Oct 6, 2025
lukevalenta
added a commit
to cloudflare/azul
that referenced
this pull request
Oct 6, 2025
See ietf-plants-wg/merkle-tree-certs#149 for details. As an added bonus, this removes a `clone()` of the proof.
lukevalenta
added a commit
to cloudflare/azul
that referenced
this pull request
Oct 7, 2025
See ietf-plants-wg/merkle-tree-certs#149 for details. As an added bonus, this removes a `clone()` of the proof.
lukevalenta
added a commit
to cloudflare/azul
that referenced
this pull request
Oct 7, 2025
See ietf-plants-wg/merkle-tree-certs#149 for details. As an added bonus, this removes a `clone()` of the proof.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Also replace prepending to the proof list with removing in the other branch. It makes it a little obvious how to implement this without making a copy of the proof. This should also hopefully make the relationship between inclusion and consistency proof evaluation clearer.
While I'm here, use '1.' for the steps so we don't have to renumber it as it changes.
(CC @nharper)